home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / prog / asm_n_z.arj / SUPPRESS.ASM < prev    next >
Assembly Source File  |  1987-03-12  |  13KB  |  479 lines

  1.  
  2. ; NOTE : This template is for .COM files only do not use for .EXE files!!
  3.  
  4.  
  5. ;
  6. ;
  7. ;
  8. ;       Copyright 1986 by Dana Nowell - All rights reserved
  9. ;
  10. ; HISTORY:
  11. ;     Version     Date         Name            Description
  12. ;       1.0     11/10/86        dn      first cut
  13. ;       1.01    11/11/86        dn      masked all foreground colors
  14. ;                                       either on or off
  15. ;       1.02    11/14/86        dn      masked all background colors
  16. ;                                       either on or off
  17. ;       1.03    11/22/86        dn      added check for already resident
  18. ;       1.04    11/23/86        dn      fixed bug with black on black displays
  19. ;       1.05    11/30/86        dn      set color suppressed mode at install
  20. ;                                       incase program checks.
  21. ;                                       moved copyright message to after
  22. ;                                       equipment check call so monochrome
  23. ;                                       can be properly determined
  24. ;       1.06    12/27/86        dn      trapped for pixel and tty writes
  25. ;                                       moved color remap to a subroutine
  26. ;                                       added mode variable to trap for
  27. ;                                       graphics mode differences
  28. ;       1.07    03/12/87        dn      trapped for dark grey on black
  29. ;
  30.  
  31. title   SUPPRESS.ASM
  32.  
  33.  
  34.  
  35.         NULL            equ     00h
  36.         BELL            equ     07h             ; bell character
  37.         BACKSPACE       equ     08h             ; backspace character
  38.         TAB             equ     09h             ; tab character
  39.         LF              equ     0ah             ; line feed
  40.         F_FEED          equ     0ch             ; form feed
  41.         CR              equ     0dh             ; carriage return
  42.         EOF             equ     1ah             ; ctrl z ( end of file )
  43.         SPACE           equ     ' '             ; ascii space character
  44.         QUOTE           equ     '"'
  45.  
  46. SIGNATURE1              equ     6144h           ; used for already
  47. SIGNATURE2              equ     616eh           ; resident check
  48.  
  49. DOS_INT                 equ     21h      ; DOS function interrupt
  50. DISP_CHAR               equ     02h
  51. GET_KEY                 equ     08h
  52. DOS_SCR_MSG             equ     09h
  53. DOS_SET_INT             equ     25h
  54. DOS_RESIDENT            equ     31h
  55. DOS_GET_INT             equ     35h
  56. DOS_TERMINATE           equ     4ch
  57. DOS_STRING_TERM         equ     '$'
  58. BIOS_ACTIVE_PAGE        equ      5
  59. BIOS_SET_VIDEO_MODE     equ      0
  60. BIOS_SET_CURSOR_SIZE    equ      1
  61.  
  62. ; Interrupt vectors used
  63.  
  64. HOOK_INT        equ    10h      ; interrupt to be hooked
  65. PAGE_NUMBER     equ     0       ; active page to be set if color moniter
  66. VIDEO_MODE      equ     2       ; color 80 x 25 with 4 grey colors
  67. CURSOR_SIZE     equ  0607h      ; color monitor cursor 6x7
  68.  
  69. ;------------------------------------------------------------------------------
  70. ;
  71. ;       MACRO   SECTION
  72. ;
  73. ;------------------------------------------------------------------------------
  74.  
  75. Version_msg     macro
  76.                 jmp     short copyright_end
  77.  
  78. copyright_msg   db      CR, LF
  79.                 db      'SUPPRESS - Version 1.07', CR, LF
  80.                 db      'Copyright 1986, Dana Nowell  ', CR, LF, CR, LF
  81.                 db      'May be distributed without license', CR, LF, '$'
  82. copyright_end:
  83.                 Msg     copyright_msg
  84.                 endm
  85.  
  86.  
  87. Msg     macro   ptr
  88.  
  89.         push    dx
  90.         push    ax
  91.  
  92.         lea     dx, ptr
  93.         mov     ah, 09h
  94.         int     21h
  95.  
  96.         pop     ax
  97.         pop     dx
  98.  
  99.         endm
  100.  
  101.  
  102.  
  103.  
  104.  
  105. com     segment para public 'code'
  106.         assume cs:com, ds:com, es:com
  107.  
  108.  
  109.         org     100h    ; required for COM file ( skips PSP )
  110.  
  111.  
  112. start:
  113.         jmp     install                 ; install the demon
  114.  
  115. ;-------------------------------------------------------------------
  116. ;
  117. ;               resident data structures go here
  118. ;
  119. ;-------------------------------------------------------------------
  120.  
  121.         old_int         dd      0       ; original value of hooked interrupt
  122.         resident1       dw      SIGNATURE1
  123.         resident2       dw      SIGNATURE2
  124.         mode            dw      0       ; 0 = text  -  1 = graphics
  125.  
  126.  
  127. ;-------------------------------------------------------------------
  128. ;
  129. ;               new interrupt starts here
  130. ;
  131. ;-------------------------------------------------------------------
  132.  
  133.  
  134. new_int:
  135.         pushf
  136.  
  137.         cmp     ah, 0eh
  138.         je      write_tty
  139.  
  140.         cmp     ah, 9
  141.         je      write_character
  142.  
  143.         cmp     ah, 0ah
  144.         je      write_attribute
  145.  
  146.         cmp     ah, 6
  147.         je      scroll
  148.  
  149.         cmp     ah, 7
  150.         je      scroll
  151.  
  152.         cmp     ah, 0ch
  153.         je      write_pixel
  154.  
  155.         cmp     ah, 13h
  156.         je      write_string
  157.  
  158.         cmp     ah, 0
  159.         je      set_mode
  160.  
  161.         jmp     do_int
  162.  
  163. write_pixel:
  164.  
  165.         push    bx              ; save bx
  166.         mov     bl, al          ; pixel color is in al so move in to bl
  167.         call    remap_color     ; remap the pixel color
  168.         mov     al, bl          ; put color back into al
  169.         pop     bx              ; restore original bx
  170.  
  171.         jmp     do_int
  172.  
  173. write_tty:
  174.  
  175.         call    remap_color     ; attribute in bl
  176.         jmp     do_int
  177.  
  178.  
  179. write_character:
  180.  
  181.         call    remap_color     ; not mixed - attribute in bl
  182.         jmp     do_int
  183.  
  184.  
  185.  
  186. write_string:
  187.  
  188.         cmp     al, 1
  189.         jg      mixed_attributes ; attribute bytes and chars mixed in a string
  190.  
  191.         call    remap_color     ; not mixed - attribute in bl
  192.         jmp     do_int
  193.  
  194. mixed_attributes:               ; stub for now
  195.         jmp     do_int
  196.  
  197.  
  198.  
  199.  
  200. scroll:
  201.         and     bh, 8fh         ; set blank lines to black
  202.         jmp     do_int
  203.  
  204.  
  205.  
  206.  
  207. set_mode:
  208.         mov     cs:mode, 0         ; mark as text mode
  209.         cmp     al, 4
  210.         jl      text
  211.  
  212.         mov     cs:mode, 1         ; really graphics mode
  213.         cmp     al, 5
  214.         jle     mgraphics
  215.         jmp     do_int
  216.  
  217. text:
  218.         cmp     al, 1
  219.         jg      htext
  220.  
  221. ltext:
  222.         mov     al, 0
  223.         jmp     do_int
  224.  
  225. htext:
  226.         mov     al, 2
  227.         jmp     do_int
  228.  
  229. mgraphics:
  230.         mov     al, 5
  231.         jmp     do_int
  232.  
  233.  
  234.  
  235.  
  236.  
  237. write_attribute:
  238.  
  239.         call    remap_color
  240.  
  241.  
  242. ;-------------------------------------------------------------------
  243. ;
  244. ;               be well behaved and pass control to original int
  245. ;
  246. ;-------------------------------------------------------------------
  247.  
  248. do_int:
  249.         popf
  250.         pushf
  251.         call   dword ptr cs:old_int     ; do old interrupt
  252.  
  253.         iret                            ; bye bye
  254.  
  255.  
  256.  
  257. remap_color     proc    near
  258.  
  259.         push    dx
  260.         push    bx
  261.  
  262. ;       test   bl, 08h
  263. ;       jz     not_grey
  264. ;
  265. ;       push   bx
  266. ;       and    bl, 77h
  267. ;       pop    bx
  268. ;       jnz    not_grey
  269.  
  270.         cmp     bl, 88h
  271.         je      grey
  272.  
  273.         cmp     bl, 08h
  274.         jne     not_grey
  275.  
  276. grey:
  277.         pop     bx
  278.         or      bl, 01h
  279.         push    bx
  280.  
  281. not_grey:
  282.         mov     dl, 00h         ; assume black background, black characters
  283.  
  284.         and     bl, 77h         ; AND color and background in character
  285.         jz      black           ; no color or background - so use default
  286.  
  287.         mov     dl, 70h         ; assume color background, black characters
  288.  
  289.         and     bl, 07h         ; and color in character
  290.         jz      black           ; no color - so use color background
  291.  
  292.         mov     dl, 07h         ; assume black background, color characters
  293.  
  294.         pop     bx              ; restore original bx
  295.         and     bl, 8fh         ; set background off leave colors on and
  296.                                 ; attributes as before ( blink & intensity )
  297.         push    bx              ; set-up for next pop
  298.  
  299. black:
  300.         pop     bx
  301.         or      bl, dl          ; mask it for readability
  302.         pop     dx
  303.  
  304.         cmp     cs:mode, 0         ; if text ret
  305.         je      remap_bye
  306.  
  307.         and     bl, 07fh        ; if graphics remove xor bit
  308.  
  309. remap_bye:
  310.         ret
  311.  
  312. remap_color     endp
  313.  
  314. ;------------------------------------------------------------------------------
  315. ;
  316. ;       INSTALLATION DATA STRUCTURES AND CODE GO HERE
  317. ;
  318. ; WARNING WARNING WARNING - this area does not exist after installation
  319. ;
  320. ;------------------------------------------------------------------------------
  321.  
  322. last_resident_byte      db      0       ; last resident byte
  323. resident_flag           dw      0       ; am I already resident ? ( 0 = NO )
  324.  
  325. install_msg             db      CR, LF
  326.                         db      'SUPPRESS - Installation Complete'
  327.                         db      CR, LF, '$'
  328.  
  329. already_installed_msg   db      CR, LF
  330.                         db      'SUPPRESS Already Installed'
  331.                         db      ' - Installation Aborted'
  332.                         db      CR, LF, '$'
  333.  
  334. mono                    db      CR, LF,
  335.                         db      'NO NEED TO SET COLOR SUPPRESSION '
  336.                         db      'ON A MONOCHROME MONITER', CR, LF, '$'
  337.  
  338. install proc    near
  339.  
  340.  
  341.  
  342. ;
  343. ;       determine monitor type
  344. ;
  345.  
  346.         int     11h                     ; determine monitor type FIRST !
  347.         and     ax, 30h
  348.  
  349.         cmp     ax, 30
  350.         jne     color_mon               ; assumes a monochrome monitor
  351.  
  352. ;
  353. ;               MONOCHROME MONITER
  354. ;
  355.         call    disp_version            ; display version message
  356.         Msg     mono                    ; if mono display print no need msg
  357.         mov     ah, DOS_TERMINATE       ; and do not install
  358.         mov     al, 1                   ; set error exit value
  359.         int     21h                     ; bye bye
  360.  
  361. ;
  362. ;               COLOR MONITER
  363. ;
  364.  
  365. color_mon:
  366.         call    color_setup           ; set video page and cursor etc.
  367.  
  368.         call    disp_version          ; display version message
  369.  
  370.          mov   al, HOOK_INT           ; int to hook
  371.          mov   ah, DOS_GET_INT        ; get int(AL) vector ==> ES+BX
  372.          int   DOS_INT                ; do the int
  373.          lea   si, old_int            ; where to put old timer interrupt vector
  374.          mov   [si], bx               ; save the offset and segment
  375.          mov   2[si], es              ; ( es also used in check resident )
  376.  
  377.          call   check_resident        ; am I already resident ?
  378.  
  379.          cmp    resident_flag, 0
  380.          je     not_resident
  381.  
  382.          Msg    already_installed_msg
  383.  
  384.          mov     ah, DOS_TERMINATE    ; terminate & stay resident
  385.          mov     al, 1                ; return value is 1 (already installed)
  386.          int     DOS_INT              ; bye-bye
  387.  
  388. not_resident:
  389.  
  390.  
  391. ;
  392. ;       setup new BIOS video interrupt routine
  393. ;
  394.  
  395.  
  396.          mov   dx, offset new_int     ; offset of new timer interrupt
  397.          mov   al, HOOK_INT           ; timer tick
  398.          mov   ah, DOS_SET_INT        ; set int(AL) vector from DS+DX
  399.          int   DOS_INT                ; do the int
  400.  
  401. ; program terminate and stay resident
  402.  
  403.          Msg     install_msg          ; Display the installation message
  404.  
  405.          mov     dx, offset last_resident_byte
  406.  
  407.          mov     cl, 4                ; convert to paragraphs required to
  408.          shr     dx, cl               ; remain resident ( divide by 16 )
  409.          inc     dx                   ; allow for any remainder of division
  410.  
  411.          mov     ah, DOS_RESIDENT     ; terminate & stay resident
  412.          mov     al, 0                ; return value is 0 (good return)
  413.          int     DOS_INT              ; bye-bye
  414.  
  415. install endp
  416.  
  417.  
  418. ;
  419. ;       Check resident procedure
  420. ;               requires es register to contain the segment address of
  421. ;               the current location for the interrupt being hooked.
  422. ;               use the DOS function 35h to obtain this information.
  423. ;
  424.  
  425. check_resident  proc    near
  426.  
  427.          cmp    es:resident1, SIGNATURE1
  428.          jne    not_res
  429.          cmp    es:resident2, SIGNATURE2
  430.          jne    not_res
  431.  
  432.          mov    resident_flag, 1
  433.  
  434. not_res:
  435.         ret
  436.  
  437. check_resident  endp
  438.  
  439. color_setup     proc    near
  440.  
  441.  
  442. ;
  443. ;       set COLOR MONITOR to use page 0
  444. ;
  445.  
  446.         mov     ah, BIOS_ACTIVE_PAGE    ; set active page function
  447.         mov     al, PAGE_NUMBER         ; page number to make active
  448.         int     10h                     ; do it
  449.  
  450.  
  451. ;
  452. ;               set video mode
  453. ;
  454.  
  455.         mov     ah, BIOS_SET_VIDEO_MODE
  456.         mov     al, VIDEO_MODE
  457.         int     10h
  458.  
  459. ;
  460. ;       set cursor size
  461. ;
  462.         mov     ah, BIOS_SET_CURSOR_SIZE
  463.         mov     cx, CURSOR_SIZE
  464.         int     10h
  465.  
  466.         ret
  467.  
  468. color_setup     endp
  469.  
  470. disp_version    proc    near
  471.  
  472.         Version_msg
  473.         ret
  474. disp_version    endp
  475.  
  476.  
  477. com     ends
  478.         end     start
  479.